package com.yq.socket1.day1.practice.test3;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

/**
 * @author 3307235355@qq.com
 * @description 客户端文本文件，服务器输出文本文件
 * @since 2022/07/01 14:23
 */
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",8888);
        OutputStream outputStream = socket.getOutputStream();
        FileInputStream inputStream = new FileInputStream("a.txt");

        byte[] bytes = new byte[1024];
        int read;
        while ((read=inputStream.read(bytes))!=-1){
            outputStream.write(bytes,0,read);
        }
        socket.shutdownOutput();

        inputStream.close();
        socket.close();
    }
}
